/*
APPENDIX TABLE 4
Share of Workers in Non-PSL Mandate Places Reporting Access to Fringe Benefits by Firm Exposure to Mandates
*/

cd "$exhibits_path"

use "$data_path/main_analysis_file.dta", clear


* define controls
	global demog i.gender i.race2_harm c.age_text_clean i.kids i.eslhome i.enrolled i.cohabstatus
	global work i.manager i.longwork_yrs i.union c.hourwage_clean c.usualhours_clean 
	global statechars c.unionmem_pc c.unemp_rate  c.minwage_state  	c.race_black c.race_amind c.race_asian c.race_pacisl c.race_other c.race_multi c.hispan c.age_u5 c.age_5to9 c.age_10to14 c.age_75to84 c.age_85plus c.female_pc c.educ_pc_hsgrad c.educ_pc_somecoll c.educ_pc_assoc c.educ_pc_bach c.educ_pc_grad
	global empchars i.shift_ind c.total_emps c.total_ests


*****************************************************Regressions********************************************************
	
*Paid sick leave	
eststo col1row1: mi est, post: reg benefits_paidsick c.pct_emps_psl_place $demog $work $statechars $empchars i.statelist i.year##i.month if psl_law_places_hybd == 0, vce(cluster statelist)

*Healthcare
eststo col1row2: mi est, post: reg benefits_health c.pct_emps_psl_place $demog $work $statechars $empchars i.statelist i.year##i.month if psl_law_places_hybd == 0, vce(cluster statelist) 

*Dental benefits
eststo col1row3: mi est, post: reg benefits_dental c.pct_emps_psl_place $demog $work $statechars $empchars i.statelist i.year##i.month if psl_law_places_hybd == 0, vce(cluster statelist)

*Paid Leave
eststo col1row4: mi est, post: reg benefits_paidleave c.pct_emps_psl_place $demog $work $statechars $empchars i.statelist i.year##i.month if psl_law_places_hybd == 0, vce(cluster statelist) 

*Retirement plan
eststo col1row5: mi est, post: reg benefits_retirementplan c.pct_emps_psl_place $demog $work $statechars $empchars i.statelist i.year##i.month if psl_law_places_hybd == 0, vce(cluster statelist) 

*tuition assistance
eststo col1row6: mi est, post: reg benefits_tuition c.pct_emps_psl_place $demog $work $statechars $empchars i.statelist i.year##i.month if psl_law_places_hybd == 0, vce(cluster statelist) 

set scheme plotplain
	
*cd "$path_results"

label var pct_emps_psl_place "\hspace{0.5cm} Percent of Workers"

*Macros for labeling control columns
estadd local demog "\checkmark": col1row1 col1row2 col1row3 col1row4 col1row5 col1row6
estadd local work "\checkmark": col1row1 col1row2 col1row3 col1row4 col1row5 col1row6
estadd local firm "\checkmark": col1row1 col1row2 col1row3 col1row4 col1row5 col1row6
estadd local state_cont "\checkmark": col1row1 col1row2 col1row3 col1row4 col1row5 col1row6
estadd local state_fe "\checkmark": col1row1 col1row2 col1row3 col1row4 col1row5 col1row6
estadd local year_fe "\checkmark": col1row1 col1row2 col1row3 col1row4 col1row5 col1row6

*Code to generate table in latex
esttab col1row1 col1row2 col1row3 col1row4 col1row5 col1row6 using "$exhibits_path/Appendix Table 4.tex", ///
	prehead("{\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi} \begin{tabular}{l*{6}{c}} \hline\hline") ///
	fragment keep(*psl*) ///
	 noomitted noconstant nonumbers nonote nodepvars ///
	 mtitles("Paid Sick Leave" "Health Insurance" "Dental Insurance" "Paid Leave" "Retirement Plan" "Tuition Assistance") ///
	 refcat(pct_emps_psl_place "\textit{Share in a PSL Covered State or County}", nolabel) ///
	 star(+ 0.10 * 0.05 ** 0.01 *** 0.001) ///
	 	 mgroups("\shortstack{PSL Access in Non-Mandate Places} " , pattern(1 0 0 0 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) /// 
		postfoot("\hline\hline \multicolumn{7}{l}{\footnotesize \sym{+} \(p<0.10\), \sym{*} \(p<0.05\), \sym{**} \(p<0.01\), \sym{***} \(p<0.001\)}\\ \end{tabular} } ") ///
	 eqlabels(none) noomitted noconstant not nonote noobs  nodepvars nonumbers label b(%9.3f) /// 
	scalars("demog Demographic Controls" "work Work Controls" "firm Firm Controls" "state_cont State Controls" "state_fe State FE" "year_fe Year, Month, Year $\times$ Month FE" "line \hline \vspace{-0.7em}" "N N") ///
	sfmt(%9.0f) ///
	prefoot("\vspace{0.1em} \\") ///
	replace

